import { Request, Response } from 'express';
import Mock from 'mockjs';

// 获取企业列表
const getEnterprises = (req: Request, res: Response) => {
  res.json({
    code: 0,
    data: Mock.mock({
      total: 100,
      'items|10': [
        {
          id: '@id',
          'number|+1': 1,
          name: '@name',
          'type|1-3': 1,
          'status|0-1': 1,
          phone: /1[0-9]{10}/,
          area: '@county(true)',
          created: '@datetime()',
          updated: '@datetime()',
        },
      ],
    }),
  });
};

// 获取所有企业
const getAllEnterprises = (req: Request, res: Response) => {
  res.json({
    code: 0,
    data: Mock.mock({
      'items|10': [
        {
          id: '@id',
          name: '企业@integer(0, 200)',
        },
      ],
    }),
  });
};

// 创建企业
const createEnterprise = (req: Request, res: Response) => {
  res.json({
    code: 0,
    data: {
      id: '@id',
    },
  });
};

export default {
  'GET /api_v1/enterprises': getEnterprises,
  'GET /api_v1/enterprises/all': getAllEnterprises,
  'POST /api_v1/enterprise': createEnterprise,
};
